<template>
	<view class="park-page">
		<!-- 顶部搜索栏 -->
		<view class="header">
			<view class="title">
				<image src="../../static/images/index/title.png" style="width: 400rpx;height: 36rpx;"></image>
			</view>
			<u-search v-model="searchText" placeholder="搜索事项、任务、内容" :show-action="false" :clearabled="true"
				shape="square"></u-search>
		</view>

		<!-- 主要服务卡片 -->
		<view class="main-services">
			<view class="service-card blue" @tap="handleService('enterprise')">
				<view class="card-content">
					<view class="card-title">企业入驻</view>
					<view class="card-desc">全方位服务保障</view>
				</view>
				<image src="/src/static/images/index/icon4.png" mode="" style="width: 70rpx;height: 70rpx;"></image>
			</view>
			<view class="service-card green" @tap="handleService('visitor')">
				<view class="card-content">
					<view class="card-title">访客服务</view>
					<view class="card-desc">简单便捷又安全</view>
				</view>
				<image src="/src/static/images/index/home.png" mode="" style="width: 70rpx;height: 70rpx;"></image>
			</view>
		</view>

		<!-- 园区情况 -->
		<view class="section">
			<view class="section-title">
				<view class="section-title-left">
					<image src="../../static/images/index/icon2.png" mode="" class="mini-icon"></image>
				</view>
				<view class="">
					园区情况
				</view>
			</view>
			<u-grid :border="false" :col="4">
				<u-grid-item v-for="item in parkStatus" :key="item.id" @click="handleGridClick(item)">
					<image :src="item.icon" mode="" class="icon"></image>
					<text class="grid-text">{{ item.title }}</text>
				</u-grid-item>
			</u-grid>
		</view>

		<!-- 园区服务 -->
		<view class="section">
			<view class="section-title">
				<view class="section-title-left">
					<image src="../../static/images/index/icon2.png" mode="" class="mini-icon"></image>
				</view>
				<view class="">
					园区服务
				</view>
			</view>
			<u-grid :border="false" :col="4">
				<u-grid-item v-for="item in parkServices" :key="item.id" @click="handleGridClick(item)">
					<!-- <u-icon :name="item.icon" :color="item.color" size="40"></u-icon> -->
					<image :src="item.icon" mode="" class="icon"></image>
					<text class="grid-text">{{ item.title }}</text>
				</u-grid-item>
			</u-grid>
		</view>

		<!-- 园区通知 -->
		<view class="section">
			<view class="section-header">
				<view class="section-title">
					<view class="section-title-left">
						<image src="../../static/images/index/icon2.png" mode="" class="mini-icon"></image>
					</view>
					<view class="">园区通知</view>
				</view>
				<view class="more" @tap="viewMore('notice')">
					更多<u-icon name="arrow-right" size="24"></u-icon>
				</view>
			</view>
			<view class="notice-list">
				<view class="notice-item" v-for="notice in notices" :key="notice.id" @tap="viewNotice(notice)">
					<text class="notice-title">{{ notice.title }}</text>
					<text class="notice-date">{{ notice.date }}</text>
				</view>
			</view>
		</view>

		<!-- 园区活动 -->
		<view class="section">
			<view class="section-header">
				<view class="section-title">
					<view class="section-title-left">
						<image src="../../static/images/index/icon2.png" mode="" class="mini-icon"></image>
					</view>
					<view class="">园区活动</view>
				</view>
				<view class="more" @tap="viewMore('activity')">
					更多<u-icon name="arrow-right" size="24"></u-icon>
				</view>
			</view>
			<view class="activity-list">
				<view class="activity-card" v-for="activity in activities" :key="activity.id"
					@tap="viewActivity(activity)">
					<image :src="activity.image" mode="aspectFill" class="activity-image" />
					<view class="activity-info">
						<text class="activity-type">园区活动</text>
						<view class="activity-detail">
							<text class="activity-time">{{ activity.time }}</text>
							<text class="activity-location">{{ activity.location }}</text>
						</view>
					</view>
				</view>
			</view>
			<up-toast ref="uToastRef"></up-toast>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	const uToastRef = ref(null)
	// 搜索文本
	const searchText = ref('')

	// 园区情况数据
	const parkStatus = ref([
		{ id: 1, title: '园区概况', url: '', icon: '../../static/images/index/icon18.png' },
		{ id: 2, title: '园区优势', url: '', icon: '../../static/images/index/icon19.png' },
		{ id: 3, title: '厂房情况', url: '', icon: '../../static/images/index/icon5.png' },
		{ id: 4, title: '投资引导', url: '', icon: '../../static/images/index/icon16.png' },
		{ id: 5, title: '园区风采', url: '', icon: '../../static/images/index/icon17.png' },
		{ id: 6, title: '招商手册', url: '', icon: '../../static/images/index/icon12.png' },
		{ id: 7, title: '智慧园区', url: '/pages/contentDetail/index?id=76', icon: '../../static/images/index/icon8.png' }
	])

	// 园区服务数据
	const parkServices = ref([
		{ id: 1, title: '园区政策', url: '/pages/parkPolicies/index', icon: '../../static/images/index/icon20.png' },
		{ id: 2, title: '报事报修', url: '/pages/reportedMaintenance/list', icon: '../../static/images/index/icon.png' },
		{ id: 3, title: '通讯录', url: '/pages/mailList/index', icon: '../../static/images/index/icon14.png' },
		{ id: 4, title: '惠生活', url: '', icon: '../../static/images/index/icon10.png' },
		{ id: 5, title: '快速对接', url: '/pages/quickDocking/index', icon: '../../static/images/index/icon11.png' },
		{ id: 6, title: '内部交流', url: '/pages/InternalCommunication/index', icon: '../../static/images/index/icon12.png' },
		{ id: 7, title: '访客服务', url: '', icon: '../../static/images/index/icon7.png' },
		{ id: 8, title: '会议室预定', url: '/pages/meetingRoomReservation/meetingRoomReservation', icon: '../../static/images/index/icon9.png' },
		{ id: 9, title: '投诉建议', url: '/pages/complaint/complaint', icon: '../../static/images/index/icon15.png' },
		{ id: 10, title: '法律服务', url: '/pages/contentDetail/index?id=73', icon: '../../static/images/index/icon6.png' },
		{ id: 11, title: '汽车租赁', url: '', icon: '../../static/images/index/icon13.png' }
	])

	// 园区通知数据
	const notices = ref([
		{
			id: 1,
			title: '关于园区停车场收费正常变更的通知',
			date: '2024-04-29'
		},
		{
			id: 2,
			title: '关于园区停车场收费正常变更的通知',
			date: '2024-04-29'
		}
	])

	// 园区活动数据
	const activities = ref([
		{
			id: 1,
			image: 'https://www.guibook.com/upload/image/202005/15908056758211805.jpg',
			time: '2024/05/01 00:00',
			location: '中华生态大厦(湖省武汉市23343路)'
		},
		{
			id: 2,
			image: 'https://www.guibook.com/upload/image/202005/15908056758211805.jpg',
			time: '2024/05/01 00:00',
			location: '中华生态大厦(湖省武汉市23343路)'
		}
	])

	// 处理点击事件
	const handleService = (type : string) => {
		uni.navigateTo({
			url: `/pages/${type}/index`
		})
	}

	const handleGridClick = (item : any) => {
		if (item.url != '') {
			uni.navigateTo({
				url: item.url
			})
		} else {
			uToastRef.value.show({
				type: 'default',
				title: '默认主题',
				message: "当前园区尚未开通该服务，暂不可使用此功能",
			});
		}

	}

	const viewMore = (type : string) => {
		uni.navigateTo({
			url: `/pages/${type}/list`
		})
	}

	const viewNotice = (notice : any) => {
		uni.navigateTo({
			url: `/pages/notice/detail?id=${notice.id}`
		})
	}

	const viewActivity = (activity : any) => {
		uni.navigateTo({
			url: `/pages/activity/detail?id=${activity.id}`
		})
	}
</script>

<style lang="scss">
	.title {
		margin-bottom: 40rpx;
	}

	.icon {
		width: 100rpx;
		height: 100rpx;
	}

	.park-page {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 30rpx;
	}

	.header {
		background-color: #fff;
		padding: 20rpx;
		margin-top: 88rpx;

	}

	.main-services {
		padding: 20rpx;
		display: flex;
		gap: 20rpx;

		.service-card {
			flex: 1;
			height: 160rpx;
			border-radius: 12rpx;
			padding: 20rpx;
			display: flex;
			align-items: center;

			image {
				margin-left: 36rpx;
			}

			&.blue {
				background: url("../../static/images/index/bg.png") no-repeat center center / cover;
			}

			&.green {
				background: url("../../static/images/index/bg2.png") no-repeat center center / cover;
			}

			.card-content {
				color: #fff;

				.card-title {
					font-size: 32rpx;
					font-weight: bold;
					margin-bottom: 10rpx;
				}

				.card-desc {
					font-size: 24rpx;
					opacity: 0.8;
				}
			}

			.card-image {
				width: 80rpx;
				height: 80rpx;
			}
		}
	}

	.section {
		margin-top: 20rpx;
		background-color: #fff;
		padding: 20rpx;

		.section-header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;

			.more {
				font-size: 24rpx;
				color: #666;
				display: flex;
				align-items: center;
			}
		}

		.section-title {
			font-family: SourceHanSansSC, SourceHanSansSC;
			font-weight: blod;
			font-size: 32rpx;
			color: #000000;
			line-height: 40rpx;
			margin-bottom: 20rpx;
			display: flex;

			.section-title-left {
				margin-right: 12rpx;
			}
		}
	}

	.grid-text {
		font-size: 24rpx;
		color: #666;
		margin-top: 10rpx;
	}

	.mini-icon {
		width: 10rpx;
		height: 30rpx;
	}

	.notice-list {
		width: 686rpx;
		height: 244rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
		border-radius: 16rpx;

		.notice-item {
			display: flex;
			justify-content: space-between;
			padding: 32rpx 0 28rpx 32rpx;
			border-bottom: 1rpx solid #eee;
			flex-direction: column;

			&:last-child {
				border-bottom: none;
			}

			.notice-title {
				font-size: 28rpx;
				color: #333;
				flex: 1;
				margin-right: 20rpx;
			}

			.notice-date {
				font-size: 24rpx;
				color: #999;
			}
		}
	}

	.activity-list {
		.activity-card {
			margin-bottom: 20rpx;
			border-radius: 12rpx;
			overflow: hidden;

			&:last-child {
				margin-bottom: 0;
			}

			.activity-image {
				width: 100%;
				height: 300rpx;
			}

			.activity-info {
				padding: 20rpx;
				background: rgba(0, 0, 0, 0.6);
				position: relative;
				margin-top: -100rpx;

				.activity-type {
					color: #fff;
					font-size: 28rpx;
					margin-bottom: 10rpx;
				}

				.activity-detail {
					display: flex;
					align-items: center;
					gap: 20rpx;

					.activity-time,
					.activity-location {
						color: rgba(255, 255, 255, 0.8);
						font-size: 24rpx;
					}
				}
			}
		}
	}
</style>